package com.mashibing.juc.c_025;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * Queue和List的区别
 * Queue添加了很多线程友好的API offer poll peek
 * BlockingQueue put take都会阻塞
 */
public class T04_ConcurrentQueue {

    public static void main(String[] args) {
        Queue<String> strs = new ConcurrentLinkedQueue<>();
        for (int i = 0; i < 10; i++) {
            strs.offer("a"+i);
        }
        System.out.println(strs);
        System.out.println(strs.size());

        System.out.println(strs.poll());//取，并且会remove掉
        System.out.println(strs.size());

        System.out.println(strs.peek());//取，并不会remove掉
        System.out.println(strs.size());
    }
}
